import VisitorIndex from '@/pages/Visitor/Visitor'
import VisitorList from '@/pages/Visitor/VisitorList'
import VisitorDesc from '@/pages/Visitor/VisitorDesc'
import { useRoutes } from 'react-router-dom'
const routeList = [
    {
        path: '/',
        element: <VisitorIndex />,
        meta: {
            title: '管理'
        },
        children: [
          {
            path: '/visitror/list',
            element: <VisitorList />,
            meta: {
              title: '列表'
            }
          },
          {
            path: '/visitror/desc',
            element: <VisitorDesc />,
            meta: {
                title: '详情'
              }
          }
        ]
    }
]
const Routes = () => {
   let route = useRoutes(routeList)
   let matches = route?.props.routeContext.outlet?.props.routeContext.matches
   if (matches) {
     let nMatches = matches.map((item:any) => ({path: item.route.path, name: item.route.meta.title}))
     window.sessionStorage.setItem('matches', JSON.stringify(nMatches))
   }
    return route
}
export default Routes;
